﻿<Window x:Class="CnmViewer.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="CnmViewer" MinHeight="500" MinWidth="500">
    <DockPanel LastChildFill="True" Margin="3">

        <ToolBar DockPanel.Dock="Top">
            <Button Name="cmdOpen" Click="cmdOpen_Click">Open folder</Button>
        </ToolBar>

        <Grid DockPanel.Dock="Left">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0"
                       TextWrapping="Wrap" Padding="10,30,10,30"
                       Focusable="{Binding ElementName=lstItems, Path=HasItems}"
                       TextAlignment="Center" MouseUp="TextBlock_MouseUp"
                       MaxWidth="{Binding ElementName=lstItems, Path=MinWidth}">
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <Trigger Property="Focusable" Value="True">
                                <Setter Property="Visibility" Value="Collapsed"></Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="FontSize" Value="15"></Setter>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
                Нажмите сюда для выбора папки с файлами писем.
            </TextBlock>

            <ListBox Grid.Row="1"
                     MinWidth="150" Name="lstItems" BorderBrush="Transparent"
                     ItemContainerStyle="{StaticResource ListBoxItemStyle}"
                     HorizontalContentAlignment="Stretch"
                     ScrollViewer.CanContentScroll="False"
                     SelectionChanged="lstItems_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0" Background="{x:Static SystemColors.WindowBrush}">
                            <Border Style="{StaticResource BorderStyle}"
                                    Padding="3"
                                    Background="{Binding Path=Background,
                                                    RelativeSource={RelativeSource 
                                                    Mode=FindAncestor,
                                                    AncestorType={x:Type ListBoxItem}}}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="{Binding Path=Time, Converter={StaticResource TimeConverter}}"></TextBlock>
                                    <TextBlock Grid.Row="1" Text="{Binding Path=File.Name}"></TextBlock>
                                </Grid>
                            </Border>

                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

        </Grid>

        <DockPanel LastChildFill="True" Name="panelView">
            <Border DockPanel.Dock="Top" Style="{StaticResource BorderStyle}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" FontWeight="Bold">From:</Label>
                    <Label Grid.Row="1" FontWeight="Bold">To:</Label>
                    <Label Grid.Row="2" FontWeight="Bold">Subject:</Label>

                    <TextBox Grid.Row="0" Grid.Column="1"
                         Style="{StaticResource TextBoxReadonlyStyle}"
                         Text="{Binding Path=From}"></TextBox>
                    <TextBox Grid.Row="1" Grid.Column="1" 
                         Style="{StaticResource TextBoxReadonlyStyle}"
                         Text="{Binding Path=To}"></TextBox>
                    <TextBox Grid.Row="2" Grid.Column="1" 
                         Style="{StaticResource TextBoxReadonlyStyle}"
                         Text="{Binding Path=Subject}"></TextBox>
                </Grid>
            </Border>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="100"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition MinWidth="100"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition MinWidth="100"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition SharedSizeGroup="groupView"></RowDefinition>
                </Grid.RowDefinitions>

                <TextBlock Grid.Column="0" Grid.Row="0" TextWrapping="Wrap" Margin="3">Заголовки</TextBlock>
                <Grid Grid.Column="0" Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="2*" MinHeight="100"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*" MinHeight="100"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Border Grid.Row="0" Style="{StaticResource BorderBigStyle}">
                        <TextBox Style="{StaticResource TextBoxReadonlyBigStyle}"
                            Text="{Binding Path=Headers}"></TextBox>
                    </Border>

                    <TextBlock Grid.Row="1" TextWrapping="Wrap" Margin="3">Вложения</TextBlock>
                    <ListBox Grid.Row="2" x:Name="lstAtt"
                             ItemsSource="{Binding Path=Files}"
                             ItemContainerStyle="{StaticResource ListBoxItemStyle}">
                        <ListBox.Style>
                            <Style TargetType="ListBox">
                                <!--<Setter Property="Visibility" Value="Collapsed"></Setter>-->
                                <Setter Property="BorderBrush" Value="Transparent"></Setter>
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                                <Setter Property="ScrollViewer.CanContentScroll" Value="False"></Setter>
                            </Style>
                        </ListBox.Style>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0" Background="{x:Static SystemColors.WindowBrush}">
                                    <Border Style="{StaticResource BorderStyle}"
                                    Padding="3"
                                    Background="{Binding Path=Background,
                                                    RelativeSource={RelativeSource 
                                                    Mode=FindAncestor,
                                                    AncestorType={x:Type ListBoxItem}}}">
                                        <Grid>
                                            <TextBlock Text="{Binding Path=Name}" TextWrapping="Wrap" Margin="2"></TextBlock>
                                        </Grid>
                                    </Border>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                </Grid>

                <GridSplitter Grid.Column="1" Grid.RowSpan="2" 
                          Width="5" VerticalAlignment="Stretch" 
                          HorizontalAlignment="Center" Background="Transparent"></GridSplitter>

                <TextBlock Grid.Column="2" Grid.Row="0" TextWrapping="Wrap" Margin="3">Простой текст</TextBlock>
                <Border Grid.Column="2" Grid.Row="1" Style="{StaticResource BorderBigStyle}">
                    <TextBox Style="{StaticResource TextBoxReadonlyBigStyle}"
                     Text="{Binding Path=TextPlain}"></TextBox>
                </Border>

                <GridSplitter Grid.Column="3" Grid.RowSpan="2" 
                          Width="5" VerticalAlignment="Stretch" 
                          HorizontalAlignment="Center" Background="Transparent"></GridSplitter>

                <TextBlock Grid.Column="4" Grid.Row="0" TextWrapping="Wrap" Margin="3">HTML</TextBlock>
                <Border Grid.Column="4" Grid.Row="1" Style="{StaticResource BorderBigStyle}">
                    <WebBrowser Name="txtHtml" Source="about:blank"></WebBrowser>
                </Border>

            </Grid>
        </DockPanel>

    </DockPanel>
</Window>
